package com.jjlin.leetcode;

public class Solution11 {
    public int maxArea(int[] height) {
        if(height == null)
            return 0;
        int res = 0, len = height.length;
        int left = 0, right = len - 1;
        while(left < right){
            int area = (right - left) * Math.min(height[left], height[right]);//计算面积
            res = Math.max(res, area);//更新最大面积
            if(height[left] < height[right])//移动较低的柱子
                left++;
            else
                right--;
        }
        return res;
    }
}
